package com.ailk.cuc.autotestbg.common.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.apache.commons.logging.Log;

public class ThreadPoolUtils {

	private static Log logger = LogUtils.getLogger(ThreadPoolUtils.class.getName());
	private static volatile ExecutorService threadPool;
	
	static{
		if(threadPool == null){
			synchronized (ThreadPoolUtils.class) {
				if(threadPool == null){
					threadPool = Executors.newFixedThreadPool(10);
					logger.debug("初始化线程池完毕");
				}
			}
		}
	}
	
	public static void execute(Runnable thread){
		threadPool.execute(thread);
		logger.debug("执行线程");
	}
	
	public static void close(){
		threadPool.shutdown();
		logger.debug("关闭线程池");
	}

}
